package com.czy.contorller.user;


import com.czy.service.UserService;
import com.czy.result.Result;
import com.czy.vo.AssetsTotalVo;
import com.czy.vo.BorrowRecordInfoVo;
import com.czy.vo.UserInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    // 获取用户信息
    @GetMapping("/info")
    public Result<UserInfoVo> UserInfo(){
        UserInfoVo userInfoVo =  userService.info();
        log.info("查询到的用户信息：{}",userInfoVo);
        return Result.success(userInfoVo);
    }

    // 获取统计数据
    @GetMapping("/stats")
    public Result<AssetsTotalVo> getAssets(){
        AssetsTotalVo assets = userService.getAssets();
        log.info("资产统计数据：{}",assets);
        return Result.success(assets);
    }

    //获取最近的借用记录数
    @GetMapping("/borrow/recent")
    public Result<List<BorrowRecordInfoVo>> getBorrowRecordInfo(){
        List<BorrowRecordInfoVo> list = userService.BorrowRecordInfo();
        log.info("10条借用记录数 {}",list);
        return Result.success(list);
    }
}
